package com.shop2cn.app.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.app.liveseller.parameter.*;
import com.shop2cn.app.liveseller.service.*;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.LiveRoomShop2cnCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.livesellerShop2cn.LiveRoom;
/**
*获取直播海报
*FreeMaker Template自动生成代码
*/
@TestSuite
//@Ignore
//直播海报需要第三方交互-小程序码-前端校验，前置条件不满足生成失败
public class Ts_GetLivePoster{
	private static GetLivePosterBean getliveposterBean;
	private static GetLivePosterCall getliveposterCall;
	private static int sellerId ;
	private static String token ;
	private static int csId;
	private static String cstoken;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取直播海报");
		try {
			sellerId =500009815;
			token=AuthCallServiceV2.createToken(sellerId, "app");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		getliveposterBean=new GetLivePosterBean();
		getliveposterCall=new GetLivePosterCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getliveposterCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	//com.shop2cn.iapi.subscription.testcase.Ts_ChargeNotify
	public void Tc_GetLivePoster_001() {
		Logger.start(true,"获取直播海报");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			GodmchManageCallService
			.editMchInfo(sellerId,"title" + sellerId,
					"http://pic1.ymatou.com/G01/M00/3F/CD/rBBlD1yTdyCAe7ruAABImnwn1Sc744_1_1_o.png",
					"autotest" + sellerId);
			
			LiveRoomShop2cnCallService.enterGroup(createlive.getId(), 1);
			getliveposterBean.setLiveId(createlive.getId());
			getliveposterCall.setData(getliveposterBean);
			String head="accesstoken="+token;
			getliveposterCall.addHeader("ymt-pars", head);
			getliveposterCall.callService();
			Logger.verifyIsContains("shop2cn", getliveposterCall.getString("posterUrl"), "验证url");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetLivePoster_002() {
		Logger.start(true,"客服获取直播海报");
		try {
			
			csId = GodmchManageCallService.bindClientService(
					sellerId, 1);
			cstoken = AuthCallServiceV2.createToken(csId, "app");
			
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);

			getliveposterBean.setLiveId(createlive.getId());
			getliveposterCall.setData(getliveposterBean);
			String head="accesstoken="+cstoken;
			getliveposterCall.addHeader("ymt-pars", head);
			getliveposterCall.callService();			
			Logger.verifyIsContains("shop2cn", getliveposterCall.getString("posterUrl"), "验证url");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}